using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_myaccount : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
             WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
        
        if(Session.Contents["jsuserid"]==null)
        {
            Response.Redirect("login.aspx");
        }
        lblAccount.Text = Session.Contents[
        "jsfullname"]+"'s account";
        hyperLinkJobApplied.NavigateUrl = 
        "~/JobSeekers/jobapplied.aspx?ResumeID=" + 
        Convert.ToString(Session.Contents["jsresume"]);
        hyperLinkContacted.NavigateUrl =
        "~/JobSeekers/recruiters.aspx?ResumeID=" +
        Convert.ToString(Session.Contents["jsresume"]);
        if(!IsPostBack)
        {
            ShowActivateResume();
        }
    }
    void ShowActivateResume()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);        
        cls.CommandText = "select  * from " +
        " vwActivateResume where UserID='"
        + Session["jsuserid"] +
         "' and  ResumeID='" + 
         Convert.ToString(Session.Contents["jsresume"]) 
         + "'";
        DataRow dataRow =
        cls.GetDataRow();
        if (dataRow != null)
        {
            hyperLinkTitle.Text = dataRow[2].ToString();
            hyperLinkTitle.NavigateUrl = 
            "resume.aspx?resumeid="+
             dataRow[1].ToString();
            hylView.NavigateUrl =
            "viewresume.aspx?resumeid=" +
            dataRow[1].ToString();
            hylEdit.NavigateUrl = 
            hylRequiredField.NavigateUrl =
            "resume.aspx?resumeid=" +
             dataRow[1].ToString();     
           if(dataRow[3].ToString() == "True")
           {
                imgRequiredField.Visible = true;
                hylRequiredField.Visible = true;
           }
           switch(dataRow[4].ToString())           
           {
            case "0":
                Literal1.Text = "Employers and Staffing Firms";
                break;
            case "1":
                Literal1.Text = "Employers";
                break;
            case "2":
                Literal1.Text = "Staffing Firms";
                break;
           }
           Literal2.Text = dataRow[5].ToString();
           Literal3.Text = dataRow[6].ToString();
           Literal4.Text = dataRow[7].ToString();
           Literal5.Text = dataRow[8].ToString();
           Literal6.Text = dataRow[9].ToString();
           
        }
    }
    protected void lbtResetStatistics_Click(object sender, EventArgs e)
    {
        if(ResetStatistics())
            ShowActivateResume();
    }
    bool ResetStatistics()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);
        cls.CommandText = "SPResetResume";
        cls.CommandType = CommandType.StoredProcedure;
        cls.ParameterCollection = new
        string[2] { "@UserID", "@ResumeID" };
        cls.ValueCollection = new
        string[2]{Convert.ToString(
            Session.Contents["jsuserid"]), 
            Convert.ToString(
            Session.Contents["jsresume"])};         
      
        return (cls.ExecuteNonQuery()>0);
    }
}
